#include "ecs_pos_sys.hpp"
#include "ecs_sys_impl_include.hpp"

namespace njm
{
    void PositionSystem::Update(float deltaTime, Coordinator &coordinator)
    {
        std::cout << "PositionSystem update" << std::endl;
        phase += deltaTime;
        float angle = phase * glm::two_pi<float>();
        float amplitude = 0.01f;
        float offsetX = amplitude * glm::sin(angle);
        float offsetY = amplitude * glm::cos(angle);
        glm::vec3 offset = glm::vec3(offsetX, offsetY, 0.0f);

        for (auto&& entity : mEntities)
        {
            auto &transform = coordinator.GetComponent<Transform>(entity);
            transform.position = transform.position + offset;
            coordinator.SetComponent<Transform>(entity, transform);
        }
    }
}
